import { Navigate } from "react-router-dom";
import AuthRoute from "@/components/AuthRoute";
import { lazy } from 'react'

// 按需导入路由组件
const Login = lazy(() => import('@/pages/Login'))
const Layout = lazy(() => import('@/pages/Layout'))
const Home = lazy(() => import('@/pages/Home'))
const Article = lazy(() => import('@/pages/Article'))
const Publish = lazy(() => import('@/pages/Publish'))

// 路由表
// eslint-disable-next-line import/no-anonymous-default-export
export default [
    {
        path: "/login",
        element: <Login></Login>
    },
    {
        path: "/layout",
        // 套上一层鉴权组件进行判断是否登录
        element: (<AuthRoute >
            <Layout></Layout>
        </AuthRoute>),
        children: [
            {
                index: true,
                element: <Home></Home>
            },
            {
                path: "article",
                element: <Article></Article>
            },
            {
                path: "publish",
                element: <Publish></Publish>
            }
        ]

    },
    {
        path: "/",
        element: <Navigate to="/layout"></Navigate>
    }
]

